<?php
 /**
 +------------------------------------------------------------------------------
 * Framk PHP框架
 +------------------------------------------------------------------------------
 * @package  Framk
 * @author   shawn fon <shawn.fon@gmail.com>
 +------------------------------------------------------------------------------
 */
 
class Action {
	 
private $value;


 /*
 +------------------------------------------------------------------------------
 * 获取数据缓存类对象：实例化数据缓存类并传入数据缓存文件夹与缓存标识; 返回值：数据缓存类对象
 +------------------------------------------------------------------------------
 */	
	public function C($cacheDir='',$cacheId='') {	
	
		return new Cache($cacheDir,$cacheId);
	}
 /*
 +------------------------------------------------------------------------------
 * 注入变量到显示页面
 +------------------------------------------------------------------------------
 * 根据传递的参数个数进行循环注入变量
 +------------------------------------------------------------------------------
 */	 
	public function assign() {
		
		$_key = @func_get_arg ( 0 );
		$_value = @func_get_arg ( 1 );
		if (is_array ( $_key )) {		
			foreach ( $_key as $k => $v ) {				
			if(is_array($v)){
			foreach ( $v as $kk => $vv ) {					 
			$this->value [$kk] = $vv;	
			}	
			} 
			$this->value [$k] = $v;			 				
			}//foreach
		} else {
			$this->value [$_key] = $_value;
		}
	}	
 /* 
 +------------------------------------------------------------------------------
 * 加载模板文件
 +------------------------------------------------------------------------------
 * 命名模板文件
 * 包含模板文件
 +------------------------------------------------------------------------------
 */	 	 
	 public function show($displayTpl='index') {
 			
		$tplFile=str_replace('/',S, VIEW.$displayTpl).'.php';		
		@extract ($this->value);
		$mtime = explode(' ',microtime());
		$GLOBALS['EndRunTime'] = (( $mtime[1] + $mtime[0]) - $GLOBALS['StartRunTime']);				
		(file_exists ($tplFile) )? require ($tplFile):_error ( 'fileNotExist', '请检查此目录下显示页面是否存在：'.$tplFile);		
		unset($this->value);
	 }
 /*
 +------------------------------------------------------------------------------
 * 获取smarty对象： 设置smarty属性并返回已设置smarty对象; 返回值：Smarty类对象
 +------------------------------------------------------------------------------
 * 根据配置文件中设置对Smarty进行设置
 +------------------------------------------------------------------------------
 */	 	 
	public function setSmarty(){
	
		$smarty=_instance(EXTEND.'smarty/Smarty');
		foreach($GLOBALS['setSmarty'] as $key=>$value){
			$smarty->$key=$value;
		}
		return $smarty;
	}

 /*
 +------------------------------------------------------------------------------
 * 跳转页面
 +------------------------------------------------------------------------------
 */	 	 
	public function location($url,$time=0) {
		 $url=ACT.'/'.$url;
		 echo '<meta http-equiv="Refresh" content='.$time.';URL='.$url.'>';
	} 
 
 /*  +------------------------------------------------------------------------------ */
}//
?>